<template>
  <div style="height: 100vh">
    <div class="bill-list bill-detail-money">
      <span>消费金额</span>
      <span>￥{{billDetail.needPayMoney | toDecimal}}</span>
    </div>
    <ul class="bill-detail">
      <li class="bill-list" v-if="billDetail.businessOrderType==buyProduct">
        <span>状态</span>
        <span v-if="billDetail.wasSafeguard==1">客服维权中</span>
        <span v-if="billDetail.orderStatus==waitForPay">待付款</span>
        <span v-if="billDetail.orderStatus==waitForDelivery">待发货</span>
        <span v-if="billDetail.wasSafeguard==0&&billDetail.orderStatus==waitForReceive">等待确认收货</span>
        <span v-if="billDetail.wasSafeguard==0&&(billDetail.orderStatus==waitForEvaluation||billDetail.orderStatus==finished||billDetail.orderStatus==invalid)">交易成功</span>
      </li>
      <li class="bill-list" v-else>
        <span>状态</span>
        <span>交易成功</span>
      </li>

      <li class="bill-list"><span>交易时间</span><span>{{billDetail.transactionTime | dateFilter}}</span></li>
      <li class="bill-list"><span>订单编号</span><span>{{billDetail.businessOrderCode}}</span></li>
    </ul>

    <div class="btn-box">
      <button class="weui-btn weui-btn_warn" type="button" @click="clickConfirm">确认</button>
    </div>

  </div>
</template>

<script>
  import Moment from 'moment';
  import {getStatusMapByKey,getUser} from "../../../../assets/js/tools";
  import {getBillDetail} from "../../../../assets/js/getData";
  export default {
    name: "billDetail",
    data(){
      return {
        billDetail:{},
        userId:null,

        waitForPay:null,//待付款5
        waitForDelivery:null,//待发货10
        waitForReceive:null,//待收货15
        waitForEvaluation:null,//待评价20
        paying:null,//支付中7
        invalid:null,//无效0
        finished:null,//交易完成50

        buyProduct:null,//购买商品1
        balanceRecharge:null,//余额充值2
        cashDepositRecharge:null,//保证金交纳3
        cashDepositDeduct:null,//保证金扣除4
        balancePut:null,//余额提现5
        cashDepositAdd:null,//获得保证金6
        cashDepositPut:null,//提取保证金7
        refund:null,//退款8
      }
    },
    created(){
      let eOrderStatus = getStatusMapByKey('eOrderStatus');
      this.invalid = eOrderStatus.invalid.val;//无效0
      this.paying = eOrderStatus.paying.val;//支付中7
      this.waitForPay = eOrderStatus.waitForPay.val;//待付款5
      this.waitForDelivery = eOrderStatus.waitForDelivery.val;//待发货10
      this.waitForReceive = eOrderStatus.waitForReceive.val;//待收货15
      this.waitForEvaluation = eOrderStatus.waitForEvaluation.val;//待评价20
      this.finished = eOrderStatus.finished.val;//交易完成50

      let eOrderType = getStatusMapByKey('eOrderType');
      this.buyProduct = eOrderType.buyProduct.val;//购买商品1
      this.balanceRecharge = eOrderType.balanceRecharge.val;//余额充值2
      this.cashDepositRecharge = eOrderType.cashDepositRecharge.val;//保证金交纳3
      this.cashDepositDeduct = eOrderType.cashDepositDeduct.val;//保证金扣除4
      this.balancePut = eOrderType.balancePut.val;//余额提现5
      this.cashDepositAdd = eOrderType.cashDepositAdd.val;//获得保证金6
      this.cashDepositPut = eOrderType.cashDepositPut.val;//提取保证金7
      this.refund = eOrderType.refund.val;//退款8

      this.userId = getUser().id;
      let billId = this.$route.query.billId;
      getBillDetail(billId).then(res => {
        if(res.data.reqResult.code>0){
          this.billDetail = res.data.data;
          console.log(res);
        }else {
          Toast(res.data.reqResult.msg);
        }
      })
    },
    filters: {
      dateFilter: (value) => {
        if(!value){
          return value;
        }
        value = value.replace(/-/g,'/');
        let data = new Date(value);
        let time = data.getTime();
        return Moment(time).format('YYYY-MM-DD HH:mm');
      }
    },
    methods:{
      clickConfirm(){
        this.$router.go(-1);
      }
    }
  }
</script>

<style scoped>
  .bill-detail{
    padding-top: 0.3rem;
  }
  .bill-list{
    display: flex;
    justify-content: space-between;
    padding: 0 0.75rem;
    height: 1.9rem;
    line-height: 1.9rem;
  }
  .bill-list span:first-child{
    color: #666666;
    font-size: 0.7rem;
    flex-shrink: 0;
  }
  .bill-list span:nth-child(2){
    color: #333333;
    font-size: 0.7rem;
  }
  .bill-detail-money{
    height: 3.2rem;
    line-height: 3.2rem;
    border-bottom: 1px solid #E5E5E5;
  }
  .bill-detail-money span:nth-child(2){
    font-size: 0.9rem;
    color: #000000;
  }
  .btn-box{
    padding: 0 2rem;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 2.7rem;
  }
</style>
